package com.alibaba.goods.storage.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.goods.storage.entity.Commentresult;
import com.alibaba.goods.storage.exception.FallBackManager;
import com.alibaba.goods.storage.exception.HandlerExceptionManager;
import com.alibaba.goods.storage.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author:RenPu
 * @Date: 2020/7/7 15:24
 * @Version: 1.0
 * @description:
 */
@RestController
@Slf4j
public class StorageController {


    @Resource
    private StorageService storageService;

    @RequestMapping(value = "/storage/decrease")
    //@SentinelResource(value = "storagedecrease",blockHandler = "handlerExceptionManagerMethond",fallback = "fallBackManagerMethond")
    public Commentresult decrease(Long productId,  Integer count){

        storageService.decrease( productId,count );
        return new Commentresult( 200,"扣除库存成功" );

    }


//    public Commentresult handlerExceptionManagerMethond(){
//        return new Commentresult( 445,"***系统繁忙o(╥﹏╥)o******------请您稍后重新--------handlerExceptionManagerMethond" );
//    }
//
//
//    public Commentresult fallBackManagerMethond(){
//        return new Commentresult( 446,"***服务异常o(╥﹏╥)o*****拼命恢复中---------------fallBackManagerMethond" );
//    }


}
